package com.china.school;

import com.china.school.pojo.User;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserFactoryBean implements FactoryBean<User> {


    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");
        System.out.println("----UserFactoryBean----获取bean对象--");
        System.out.println(ctx.getBean("user4"));
        System.out.println("----UserFactoryBean----获取本身对象--");
        System.out.println(ctx.getBean("&user4"));
    }

    @Override
    public User getObject() throws Exception {
        User user = new User();
        user.setUsername("jack");
        user.setPassword("if0-5u9g0f7e902374");
        return user;
    }

    @Override
    public Class<?> getObjectType() {
        return User.class;
    }
}
